<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>饭否-登录</title>
	<link rel="stylesheet" type="text/css" href="/FAFCode/UserManagement/css/reset.css">
	<link rel="stylesheet" type="text/css" href="/FAFCode/UserManagement/css/main.css">
	<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
	<%
		Object obj_prepage = request.getSession().getAttribute("pre-page");
	%>
</head>
<body>
<script type="text/javascript" src="https://cdn.bootcss.com/canvas-nest.js/1.0.1/canvas-nest.min.js"></script>
	<div class="login_top clearfix">
		<a href="Index" class="login_logo"><img src="images/logo02.png"></a>	
	</div>
	<label id="prepage" hidden=true><%=null == obj_prepage ? "/FAFCode/Index" : obj_prepage.toString() %></label>
	<div class="login_form_bg">
		<div class="login_form_wrap clearfix">
			<div class="login_banner fl"></div>
			<div class="slogan fl">日夜兼程 · 急速送达</div>
			<div class="login_form fr">
				<div class="login_title clearfix">
					<h1>用户登录</h1>
					<a href="register.jsp">立即注册</a>
				</div>
				<div class="form_input">
					<br>
						<input type="text" name="user_number" id="user_number" class="name_input" placeholder="请输入用户名">
						<br>
						<br>
						<font face=宋体  size=2.2 color="red"  >
							<div id="test" > · </div>
						</font>
						<br>
						<div class="user_error">输入错误</div>
						<input type="password" name="user_pwd" id="user_pwd" class="pass_input" placeholder="请输入密码">
						<br>
						<br>
						<div class="pwd_error">输入错误</div>
						<font face=宋体  size=2.2 color="red">
							<div id="test2" > · </div>
						</font>
						<div class="rand">
						<input type="text" name="rand" id="rand" size="10" placeholder="请输入验证码" >
						<img name="randImage" id="randImage" src="/FAFCode/UserManagement/image.jsp" width="60" height="20" border="1" align="absmiddle" >
						<a href="javascript:loadimage();">
							<font class=pt95 id="randTip">看不清点我</font>
						</a>
						<div2 class="more_input clearfix">
							<input type="checkbox" name="" id="checkbox">
							<label>记住用户名</label>
							<a href="#">忘记密码</a>
						</div2>
						</div>					
						
					<input type="button" name="" value="登录" class="input_submit" onclick="logincheck()" >
				</div>
			</div>
		</div>
	</div>
	<div class="footer no-mp">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2020 南昌航空大学软件科技园技术有限公司 All Rights Reserved</p>
		<p>电话：110   昌ICP备*******8号</p>
	</div>
<script type="text/javascript">
	function loadimage(){ 
		document.getElementById("randImage").src = "image.jsp?"+Math.random(); 
	} 
    function logincheck(){
	  var account = document.getElementById("user_number").value;
	  var pwd = document.getElementById("user_pwd").value;
	  var rand = document.getElementById("rand").value;
	  var pre_page = document.getElementById("prepage").innerHTML;
	  var rand_check = true;
	  var count=0;
    $.ajax({
	   method:"post",
	   url:"${pageContext.request.contextPath}/UserLogin",
	   data:{user_number:account,user_pwd:pwd,rand:rand,rand_check:rand_check},
	   dataType: "json",
	   success: function(data){
		
		   if(data.code== 0  )
		  	   $("#test").text("用户名或密码错误");
		   if(data.code== 3  ){
			   $("#test").text("验证码错误");
		   		loadimage();
		   }
		   if(data.code== 4  ){
			   $("#test2").text("密码错误超过3次，请输入验证码");
			   loadimage();
			   $("#rand").slideDown("fast");
			   $("#randImage").slideDown("fast");
			   $("#randTip").slideDown("fast");
			   $("div2").css("top","158px");
		   }
		   if(data.code== 2  )
			   $("#test").text("请输入用户名");
		   if(data.code== -1  )
			   $("#test").text("用户名不存在");
		   if(data.code== -2  )
			   $("#test").text("请输入密码");
		   if(data.code== 1  ){
			   $("#test").text("登陆成功");
			   $("#test2").text("");
			   $("div2").css("top","150px");
			   window.location.href=pre_page;
		   }
		   if(data.code== -3  )
			   $("#test").text("请输入验证码");
	   }
  	});
  }; 
	
 </script>
</body>

</html>